﻿#include "MdbPrimaryKeyComp.h"
#include <string.h>
#include <string>
#include <functional>

using std::string;


namespace mdb
{
	bool TickEqualForTickPrimaryKey::operator()(const Tick* const left, const Tick* const right) const
	{
		return left->TradingDay == right->TradingDay && strcmp(left->ExchangeID, right->ExchangeID) == 0 && strcmp(left->InstrumentID, right->InstrumentID) == 0 && left->UpdateTs == right->UpdateTs;
	}
	size_t TickHashForTickPrimaryKey::operator()(const Tick* const record) const
	{
		return std::hash<long long>()(record->TradingDay) + std::hash<string>()(record->ExchangeID) + std::hash<string>()(record->InstrumentID) + std::hash<long long>()(record->UpdateTs);
	}

	bool BarEqualForBarPrimaryKey::operator()(const Bar* const left, const Bar* const right) const
	{
		return left->TradingDay == right->TradingDay && strcmp(left->ExchangeID, right->ExchangeID) == 0 && strcmp(left->InstrumentID, right->InstrumentID) == 0 && left->UpdateTs == right->UpdateTs;
	}
	size_t BarHashForBarPrimaryKey::operator()(const Bar* const record) const
	{
		return std::hash<long long>()(record->TradingDay) + std::hash<string>()(record->ExchangeID) + std::hash<string>()(record->InstrumentID) + std::hash<long long>()(record->UpdateTs);
	}

}
